package weixinkeji.dev.dc.buy.order.sql;

import sys.wx.ann.AF;
import sys.wx.ann.tc.bean.objectTC.TC;
import weixinkeji.dev.dc.buy.order.bean.FWYOrder;
import weixinkeji.dev.dc.buy.order.bean.FWYOrderB;
import weixinkeji.dev.dc.buy.order.xy.FWYOrderXY;

/**
 *
 * @author imyweb
 */
public class FWYSQL {

//    /**
//     * 修改订单的价格<p>
//     * ?1:增长的价格<p>
//     * ?2:表头ID
//     */
//    public static final String SQL_UPDATE_ORDER_SUMPRICE;
    /**
     * 修改订单的价格(通过统计清单总和的方式)
     * <p>
     * ?2:表头ID
     */
    public static final String SQL_UPDATE_ORDER_SUMPRICE_BY_SUMF;

    /**
     * 变更订单状态<p>
     * ?1:订单状态<p>
     * ?2:表头ID
     */
    public static final String SQL_UPDATE_ORDER_SORT;

    /**
     * 变更订单-表体的状态<p>
     * ?1:订单里，清单的状态<p>
     * ?2:表头ID
     */
    public static final String SQL_UPDTAE_ORDER_B_STYLE;

    /**
     * 变更订单-表体的上台数量及状态<p>
     * ?1:订单里，清单的状态<p>
     * ?2:上台数量 ?3:订单表体的 ID
     */
    public static final String SQL_UPDATE_ORDER_B_LOCKNUMBER_STYLE;

    /**
     * 变更订单表体旧的状态<p>
     * ?1:订单里，清单新的状态<p>
     * ?2:条件，表头ID<P>
     * ?3:条件，清单中，旧状态
     */
    public static final String SQL_UPDTAE_ORDER_B_STYLE_OLD;
    /**
     * 删除订单里-无效的清单<p>
     * ?2:表头ID
     */
    public static final String SQL_DELL_ORDER_B_NUMBER_0;
    /**
     * 删除订单里-开立的清单<p>
     * ?2:表头ID
     */
    public static final String SQL_DELL_ORDER_B_STYLE_1;

    /**
     * 统计指定表单?1的某食物?2的购卖数量<p>
     * ?1:表头ID<p>
     * ?2:表体ID
     */
    public static final String SQL_SELECT_SUM_ORDERB_BUYNUMBER;

    static {
        TC ftc = AF.getTC(FWYOrder.class);
        TC fbtc = AF.getTC(FWYOrderB.class);

//        SQL_UPDATE_ORDER_SUMPRICE = "UPDATE " + ftc.talbeName
//                + " SET order_sumprice=order_sumprice+?1"
//                + " WHERE " + ftc.mID.tcName + "='?2'";
        SQL_UPDATE_ORDER_SUMPRICE_BY_SUMF = "UPDATE " + ftc.talbeName
                + " SET order_sumprice=(SELECT SUM(buy_sum*1000)/1000 FROM " + fbtc.talbeName + " WHERE " + ftc.mID.tcName + "='?2') "
                + " WHERE " + ftc.mID.tcName + "='?2'";

        SQL_UPDATE_ORDER_SORT = "UPDATE " + ftc.talbeName
                + " SET order_sort='?1'"
                + " WHERE " + ftc.mID.tcName + "='?2'";

        SQL_UPDTAE_ORDER_B_STYLE = "UPDATE " + fbtc.talbeName
                + " SET orderb_style='?1'"
                + " WHERE " + ftc.mID.tcName + "='?2'";

        SQL_UPDTAE_ORDER_B_STYLE_OLD = SQL_UPDTAE_ORDER_B_STYLE + " AND  orderb_style='?3'";

        SQL_DELL_ORDER_B_NUMBER_0 = "DELETE FROM " + fbtc.talbeName
                + " WHERE  " + ftc.mID.tcName + "='?2' AND buy_number=0";

        SQL_DELL_ORDER_B_STYLE_1 = "DELETE FROM " + fbtc.talbeName
                + " WHERE  " + ftc.mID.tcName + "='?2'  AND orderb_style=" + FWYOrderXY.B_STYLE_1;

        SQL_SELECT_SUM_ORDERB_BUYNUMBER = "SELECT SUM(buy_number) FROM " + fbtc.talbeName
                + " WHERE order_id='?1' AND source_id='?2' AND orderb_style<>1;";

        SQL_UPDATE_ORDER_B_LOCKNUMBER_STYLE = "UPDATE " + fbtc.talbeName
                + " SET orderb_style=?1,orderb_lock_number=?2 WHERE orderb_id='?3'";
    }
}
